home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 June (DVD) / DPPRO0605DVD.iso / Install / program files / Borland / BDS / 3.0 / Demos / Delphi.Net / CLR / Shapes / Line.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2004-10-22  |  1.2 KB  |  47 lines

  1. unit Line;
  2. {*******************************************************************************
  3.   ShapesDemo
  4.   Written by David Clegg, davidclegg@optusnet.com.au.
  5.  
  6.   This unit contains the Line class used to render a line onto a GDI+ drawing
  7.   surface.
  8. *******************************************************************************}
  9.  
  10. interface
  11.  
  12. uses
  13.   Shape, System.Drawing, System.Drawing.Drawing2D;
  14.  
  15. type
  16.  
  17.   /// <summary>
  18.   /// Class to draw a Line.
  19.   /// </summary>
  20.   TLine = class(TShape)
  21.   protected
  22.     function GetShape(pStartPoint, pEndPoint: Point): GraphicsPath; override;
  23.   public
  24.     procedure DrawLine(pPen: Pen; pStartPoint, pEndPoint: Point);
  25.   end;
  26.  
  27. implementation
  28.  
  29. /// <summary>
  30. /// Create a GraphicsPath object representing the bounds for the Line
  31. /// </summary>
  32. function TLine.GetShape(pStartPoint,pEndPoint: Point): GraphicsPath;
  33. begin
  34.   Result := GraphicsPath.Create;
  35.   Result.AddLine(pStartPoint, pEndPoint);
  36. end;
  37.  
  38. /// <summary>
  39. /// Alternative method to draw a Line.
  40. /// </summary>
  41. procedure TLine.DrawLine(pPen: Pen; pStartPoint, pEndPoint: Point);
  42. begin
  43.   Canvas.DrawLine(pPen, pStartPoint, pEndPoint);
  44. end;
  45.  
  46. end.
  47.